﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace TrinitySequenceAssembly
{
    class FastaReader
    {
        string m_FilePath;
        StreamReader m_FileReader;
        public FastaReader(string filePath)
        {
            m_FilePath = filePath;
            InitializeFileReader();
        }

        private void InitializeFileReader()
        {
            m_FileReader = null;
            try
            {
                m_FileReader = new StreamReader(new BufferedStream(new FileStream(m_FilePath, FileMode.Open, FileAccess.Read)));
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                Console.WriteLine(e.StackTrace);
            }
        }

        public string Read()
        {
            string res = null;
            try
            {
                if (m_FileReader.EndOfStream == false)
                {
                    res = m_FileReader.ReadLine();
                    res = m_FileReader.ReadLine();
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                Console.WriteLine("fasta file is not a correct format!");
            }
            return res;
        }

        public void Close()
        {
            if (m_FileReader != null)
            {
                m_FileReader.Close();
            }
        }

    }
}
